package br.com.projeto.dao.hql;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;

import br.com.projeto.sakila.bean.Inventory;
import br.com.projeto.sakila.bean.Language;

public class LanguageDao {
	
	private SessionFactory sessionFactory;
	private Session session;

	public LanguageDao(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	
	public long buscarLanguage(){
		long tempoInicial = System.currentTimeMillis();
		List<Language> listaLanguage = new ArrayList<>();
		try{
			session = sessionFactory.openSession();
			listaLanguage = session.createQuery("from Language").list();
			session.close();
		} catch (Exception e){
			System.err.println("Error");
		}
		long tempoFinal = System.currentTimeMillis(); 
		long tempo = tempoFinal - tempoInicial;
		return tempo;
	}
	
	public void listarLanguage(List<Language> lista){
		System.out.println("---------------------------");
		for (Language language : lista) {
			System.out.println("ID : " + language.getId());
			System.out.println("Nome : " + language.getNome());
			//TODO:falta campos

			System.out.println("---------------------------");
		}
	}

}
